package com.woniuxy.caradmin.service.impl;

import com.woniuxy.caradmin.entity.pojo.Role;
import com.woniuxy.caradmin.mapper.RoleMapper;
import com.woniuxy.caradmin.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Override
    public List<Role> selectAllRole() {
        return roleMapper.selectAllRole();
    }

    @Override
    public Integer insertRole(Role role) {
        return roleMapper.insertRole(role);
    }

    @Override
    public Integer delectRole(Integer id) {
        return roleMapper.delectRole(id);
    }

    @Override
    public Integer updateRole(Role role) {
        return roleMapper.updateRole(role);
    }

    @Override
    public List<Role> selectByName(Role role) {
        return roleMapper.selectByName(role);
    }

    @Override
    public List<Role> selectUserWithRole(Integer uid) {
        return roleMapper.selectUserWithRole(uid);
    }

    @Override
    public boolean delectAllPath(Integer[] ids) {
        if (ids!=null&&ids.length>0){
            for(Integer id:ids){
                roleMapper.delectRole(id);
            }
        }
        return true;
    }
}
